<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>insert title here</title>
</h:head>
<h:body>
	<ui:composition template="/templates/khungchinh.xhtml">
		<ui:define name="tieudetrang">
            #{msgs.tieudetrangquanly}
         </ui:define>
		<ui:define name="javascrip">
			<h:outputScript library="javascrip" name="quanlysanpham.js" />
		</ui:define>
		<ui:define name="phandau">
			<div class="daude">#{msgs.loichaotrangadmin}</div>
		</ui:define>
		<ui:define name="menungang">
		<h:form>
			<p:tabMenu activeIndex="1">  
    		<p:menuitem value="Thêm Sản Phẩm" url="admin.xhtml" styleClass="menuitem" />  
    		<p:menuitem value="Quản Lý Sản Phẩm" url="#" styleClass="menuitem"/> 
    		<p:menuitem value="Quản Lý Hóa Đơn" url="quanlyhoadon.xhtml" styleClass="menuitem"/>   
			<p:menuitem value="Log Out" action="#{beanSanPham.logout}"
					styleClass="menuitem" />
			</p:tabMenu>
			</h:form>
		</ui:define>
		<ui:define name="noidung">
		
		
			<div id="menu">
			<h:form>
				<p:menu model="#{beanQuanLy.model}" styleClass="menu">
				</p:menu>
			</h:form>
			</div>
			
			
			<div id="dsspadmin">
			<h:form id="form">
			<p:dataTable  value="#{beanQuanLy.dataModel}" var="sanpham"
					rowKey="#{sanpham.ten}" paginator="true" rows="10"
					rowsPerPageTemplate="10,15,20,25"  
                selection="#{beanQuanLy.selectedSanPham}" selectionMode="single" 
                id="bangsanpham" styleClass="datatable">  
  
  <p:ajax event="rowSelect" update=":form:display" oncomplete="sanphamDialog.show()" >
  </p:ajax>
        <f:facet name="header">  
            #{beanQuanLy.tieude}  
        </f:facet>  
  
        <p:column headerText="Tên" filterBy="#{sanpham.ten}" sortBy="#{sanpham.ten}" id="tensanpham">  
            #{sanpham.ten}  
        </p:column>  
  
        <p:column headerText="Hãng" filterBy="#{sanpham.nhasanxuat.tennhasanxuat}" sortBy="#{sanpham.nhasanxuat.tennhasanxuat}" id="nhasanxuat">  
            #{sanpham.nhasanxuat.tennhasanxuat}  
        </p:column>  
  
        <p:column headerText="Giá" filterBy="#{sanpham.gia}" sortBy="#{sanpham.gia}" id="gia">  
            <h:outputText value="#{sanpham.gia}">
            <f:convertNumber pattern="###,###,### VND"></f:convertNumber>
            </h:outputText>
        </p:column>  
    	<p:column>  
            <p:button value="Sửa" outcome="suasanpham?ten=#{sanpham.ten}" styleClass="button" disabled="#{beanQuanLy.kiemtrahoadon(sanpham)}">
            </p:button>
            <p:commandButton value="Xóa" styleClass="button" action="#{beanQuanLy.xoasanpham}" disabled="#{beanQuanLy.kiemtrahoadon(sanpham)}">
            <f:setPropertyActionListener target="#{beanQuanLy.selectedSanPham}"
			value="#{sanpham}"></f:setPropertyActionListener>
			<p:ajax update="bangsanpham"></p:ajax>
            </p:commandButton>
        </p:column> 
    </p:dataTable>  
    
    <p:dialog header="Chi Tiết Sản Phẩm" widgetVar="sanphamDialog" resizable="false"  
              width="400" showEffect="explode" hideEffect="explode">
                
        <h:panelGrid id="display" columns="2" cellpadding="4" styleClass="tooltip">  
  
            <f:facet name="header">  
                <p:graphicImage value="/resources/images/hinhsanpham/#{beanQuanLy.selectedSanPham.hinh}"/>  
            </f:facet>  
            
  			<h:outputText value="Tên:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.ten}" id="ten"/>
            
            <h:outputText value="Giá:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.gia}" id="gia">
            <f:convertNumber pattern="###,###,### VND"></f:convertNumber>
            </h:outputText>  
  
            <h:outputText value="Hãng:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.nhasanxuat.tennhasanxuat}" id="hang"/>  
  
            <h:outputText value="Bảo Hành:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.baoHanh}" id="baohanh"/>
            
            <h:outputText value="CPU:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.cpu}" id="cpu"/>  
            
            <h:outputText value="Ram:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.ram}" id="ram"/>
            
            <h:outputText value="HDD:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.hdd}" id="hdd"/>
            
            <h:outputText value="Màn Hình:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.manHinh}" id="manhinh"/>
            
            <h:outputText value="Đồ Họa:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.doHoa}" id="dohoa"/>
            
            <h:outputText value="Ổ Đĩa:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.oDia}" id="odia"/>
            
            <h:outputText value="Wifi:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.wifi}" id="wifi"/>
            
            <h:outputText value="Webcam:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.webcam}" id="webcam"/>
            
            <h:outputText value="Pin:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.pin}" id="pin"/>
            
            <h:outputText value="Hệ Điều Hành:" style="font-weight: bold;"/>  
            <h:outputText value="#{beanQuanLy.selectedSanPham.hdh}" id="hdh"/>
            
            <h:outputText value="Khuyến Mãi: " style="font-weight: bold; color: red; "></h:outputText>
			<h:outputText escape="false" value="#{beanQuanLy.selectedSanPham.khuyenMai}"></h:outputText>
            
        </h:panelGrid>  
    </p:dialog> 
				</h:form>
			</div>
			
			
		</ui:define>
	</ui:composition>

</h:body>
</html>